#include <./libdepythonize_c.h>

#include <./translate.h>
#include <./debug_print.h>

#include <string.h>

extern "C" char* translate_c(const char* code_c){
  std::string code(code_c);
  std::string code_o = translate(code);
  const char* str_temp = code_o.c_str();
  size_t len = strlen (str_temp);
  char* str_c_return = (char*)malloc( len + 1);
  memcpy(str_c_return, str_temp, len);
  str_c_return[len] = 0;
  //printf("en libdepythonize_c: len %d \n %s \n", len, str_c_return)
  //std::cout << "C++ "<<code_o <<"\n"
  return str_c_return;}

extern "C" char* print_tokens_c(const char* code_c){
  std::string code(code_c);
  //const char* str_temp = print_tokens(code).c_str()
  std::string code_o = print_tokens(code);
  const char* str_temp = code_o.c_str();
  size_t len = strlen (str_temp);
  char* str_c_return = (char*)malloc( len + 1);
  memcpy(str_c_return, str_temp, len);
  str_c_return[len] = 0;
  //printf("en libdepythonize_c: len %d \n %s \n", len, str_c_return)
  //std::cout << "C++ "<<code_o <<"\n"
  return str_c_return;}

extern "C" void free_mem(char* mem_to_free){
  free(mem_to_free);}

//--helper--
